<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="UTF-8">
    <title>添加线索</title>
    
	<meta name="pragma" content="no-cache">
	<meta name="cache-control" content="no-cache">
	<meta name="content-type" content="text/html;charset=UTF-8">
	<meta name="expires" content="0">   
<!--    <%@include file="../../script.html" %>-->
	  <div th:replace="~{commons/script::script}"></div>
<!--	  <div th:replace="~{commons/script::_css}"></div>-->
<!--    <link href="http://www.easyui-extlib.com/Content/Site.css" rel="stylesheet" />-->
<!--    <script src="http://www.easyui-extlib.com/Scripts/jquery-extensions/jquery.jdirk.js"></script>-->
<!--    <link href="http://www.easyui-extlib.com/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.css" rel="stylesheet" />-->
<!--    <script src="http://www.easyui-extlib.com/Scripts/jquery-easyui-extensions/validatebox/jeasyui.extensions.validatebox.rules.js"></script>-->
    
  </head>
   <style>
  	*{
  		margin-left: 10px;
  		padding: 3px;	
  	}
  	.tip{
  		
  		height:30px;
  		text-align: right;
  		background-color: #F5F5F5;
  	}
	.addtable{
		height:550px;
	}
	.addtable tr{
		margin:60px !important;
		height:36px;
	}
	.addtable tr td{
		padding-left:5px;
	}
  </style>

  <body>

  	<form id="newCustomer" method="post">
  		<input type="hidden" name="id" th:value="${leads.id }">
<!--  		<input type="hidden" name="customerVO.isDeleted" value="${false}">-->
<!--  		<input type="hidden" name="customerVO.isLocked" value="${false}">-->
<!--  		<input type="hidden" name="customerVO.contactId" value="${customerVO.contactId }">-->
<!--  		<input type="hidden" name="customerVO.contactCreateUserId" value="${customerVO.contactCreateUserId }">-->
<!--  		<input type="hidden" name="customerVO.contactCreateTime" value="${customerVO.contactCreateTime }">-->
<!--  		<input type="hidden" name="customerVO.createUserId" value="${customerVO.createUserId }">-->
<!--  		<input type="hidden" name="customerVO.createTime" value="${customerVO.createTime}">-->
	<h3></h3>
	<table class="addtable">
    	<tr>
    		<td colspan="4">主要信息</td>
    	</tr>
    	<tr>
			<td class="tip">负责人：</td>
			<td>
				<select class="easyui-combobox" name="ownerUserId" style= "width:146px">
					<option  value="0">-请选择-</option>
					<option th:each="user:${users}" th:value="${user.id}" th:text="${user.username}" th:selected="${leads.ownerUserId==user.id?true:false}">-请选择-</option>
				</select>
			</td>
<!--    		<td class="tip">负责人：</td>-->
<!--    		<td>-->
<!--				<input name="ownerUserId" class="easyui-textbox easyui-validatebox" data-options="prompt:'负责人',validType:['chinese'],required:false"/>-->
<!--				&nbsp;<a href="javascript:void(0);" class="easyui-linkbutton button-white">放入线索池</a>-->
<!--			</td>-->
    		<td class="tip">公司名称：</td>
    		<td><input name="name" placeholder="公司名称" class="easyui-textbox easyui-validatebox"
					   th:value="${leads.name}" data-options="prompt:'公司名称',validType:['chinese'],required:false"/></td>
    	</tr>
    	<tr>
    		<td class="tip">来源：</td>
    		<td>
				<select class="easyui-combobox" name="source" style= "width:146px">
					<option value="其他" th:selected="${#strings.equals('其他',leads.source)}">-请选择-</option>
					<option value="展览会" th:selected="${#strings.equals('展览会',leads.source)}">展览会</option>
					<option value="广告" th:selected="${#strings.equals('广告',leads.source)}">广告</option>
					<option value="网络" th:selected="${#strings.equals('网络',leads.source)}">网络</option>
					<option value="媒体" th:selected="${#strings.equals('媒体',leads.source)}">媒体</option>
				</select>
			</td>
    		<td class="tip">联系人姓名：</td>
    		<td><input name="contactsName" th:value="${leads.contactsName}" class="easyui-textbox easyui-validatebox" data-options="prompt:'联系人姓名',required:true"/></td>
    	</tr>
    	<tr>
    		<td class="tip">职位：</td>
    		<td>
				<input name="position"  class="easyui-textbox easyui-validatebox" data-options="prompt:'职位',required:false" th:value="${leads.position}"/>
			</td>
    		<td class="tip">尊称：</td>
    		<td>
				<input name="saltname" class="easyui-textbox easyui-validatebox" data-options="prompt:'尊称',required:false" th:value="${leads.saltname}"/>
			</td>
    	</tr>
    	<tr>
    		<td class="tip">手机：</td>
    		<td>
				<input name="mobile" class="easyui-textbox easyui-validatebox" data-options="prompt:'手机',required:true" th:value="${leads.mobile}"/>
			</td>
    		<td class="tip">邮箱：</td>
    		<td>
				<input name="email" placeholder="邮箱" class="easyui-textbox easyui-validatebox" data-options="prompt:'邮箱',required:false" th:value="${leads.email}"/>
			</td>
    	</tr>
    	<tr>
    		<td class="tip">地址：</td>
    		<td colspan="3">
    			<input id="addr1"class="easyui-textbox easyui-validatebox" style="width:100px" data-options="prompt:'省',required:true">
    			<input id="addr2" class="easyui-textbox easyui-validatebox" style="width:100px" data-options="prompt:'市',required:true">
    			<input id="addr3" class="easyui-textbox easyui-validatebox" style="width:100px" data-options="prompt:'区',required:true">
    			<input id="addr4" class="easyui-textbox easyui-validatebox" data-options="prompt:'具体街道信息',required:true">
    			<input id="address" th:value="${leads.address}" name="address" type="hidden">
    		</td>
    	</tr>
		<tr>
			<td class="tip">下次联系时间：</td>
			<td>
				<input name="nextstepTime" class="easyui-textbox easyui-validatebox" th:value="${#dates.format(leads.nextstepTime,'yyyy-MM-dd')}" data-options="prompt:'下次联系时间',required:false"/>
			</td>
			<td class="tip">下次联系内容：</td>
			<td><input name="nextstep" class="easyui-textbox easyui-validatebox" th:value="${leads.nextstep}" data-options="prompt:'下次联系内容',validType:['zipCode'],required:false"/></td>
		</tr>
    	<tr>
    		<td colspan="4">附加信息</td>
    	</tr>
    	<tr>
			<td class="tip">备注：</td>
    		<td colspan="3">
    			<textarea class="easyui-textbox" name="leadnote" th:text="${leads.leadnote}" data-options="prompt:'备注',multiline:true" style="width:579px;height:60px;"></textarea>
    		</td>
    	</tr>
    	<tr>
    		<td colspan="4" style="text-align: center;">
    			<a id="save" href="javascript:void(0);" class="easyui-linkbutton button-purple" >保存</a>
    			<a id="submit" href="javascript:void(0);" class="easyui-linkbutton button-pink" >保存并新建</a>
<!--				<button id="submit" type="submit" class="easyui-linkbutton button-pink" >保存并新建</button>-->
				<a class="easyui-checkbox">返回</a>

    		</td>
    	</tr>
    </table>
    </form>
  </body>
  <script type="text/javascript">
  	$(function(){
		var addr = $("#address").val();
		var strings = addr.split("-");
		$("#addr1").textbox({"value":strings[0]});
		$("#addr2").textbox({"value":strings[1]});
		$("#addr3").textbox({"value":strings[2]});
		$("#addr4").textbox({"value":strings[3]});

  		// $.post("system/user/UserAction_findAll.action",function(data){
  		// 	if(data&&data.success){
  		// 		var ownerId = "${customerVO.ownerId}";
  		// 		$.each(data.data,function(index,obj){
  		//
  		// 			var option = $("<option value='"+obj.id+"' >"+obj.username+"</option>")
  		// 			if(ownerId == obj.id){
  		// 				option.prop("selected",true);
  		// 			}
  		// 			$("#owner").append(option);
  		// 		})
  		// 	}
  		// },"json")
  		//修改回显地址
  		// var address = "${customerVO.address}";
  		// address = address.split("-");
  		// $("#addr1").textbox({"value":address[0]});
  		// $("#addr2").textbox({"value":address[1]});
  		// $("#addr3").textbox({"value":address[2]});
  		// $("#addr4").textbox({"value":address[3]});
  		
  		$("#save").on("click",function(e){
  			$("#newCustomer").form("submit",{
				url:"/leads/updateLeads",
  				onSubmit:function(){
  					return $(this).form("validate");
  				},
  				success:function(data){
  					var tdata=eval("("+data+")");
  					if(tdata&&tdata.success){
  						parent.parent.$("#topWindow").window("close");
  					}
  				}
  			})
  			
  		})
  	})
  </script>
</html>
